<div class="menu_top">
	<input type="hidden" name="action" value="list_attribute">
    <input type="hidden" id="del_att_id" name="del_att_id" value="0" />
	<img class="icon command" src="<?php echo SYSICONS_URL; ?>filesave_22.gif" onclick="edit_form.submit();"  />
</div>
<div class="menu_list">
<table id="menulist" class="item_list" cellspacing="0" cellpadding="0" border="0">
	<thead class="fields">
        <tr>
            <th class="first"><?php echo ucfirst($txt->getWord('id')); ?></th>
            <th><?php echo ucfirst($txt->getWord('title')); ?></th>
            <th><?php echo ucfirst($txt->getWord('import').' '.$txt->getWord('title')); ?></th>
            <th><?php echo ucfirst($txt->getWord('effect')); ?></th>
            <th><?php echo ucfirst($txt->getWord('effects_image')); ?></th>
            <th><?php echo ucfirst($txt->getWord('value').' '.$txt->getWord('types')); ?></th>
            <th><?php echo ucfirst($txt->getWord('predefined')); ?></th>
            <th><?php echo ucfirst($txt->getWord('type')); ?></th>
            <th><?php echo ucfirst($txt->getWord('display')); ?></th>
            <th><?php echo ucfirst($txt->getWord('list_display')); ?></th>
            <th><?php echo ucfirst($txt->getWord('display_all')); ?></th>
            <th><?php echo ucfirst($txt->getWord('active')); ?></th>
            <th><?php echo ucfirst($txt->getWord('edit')); ?></th>
            <th class="last"><?php echo ucfirst($txt->getWord('delete')); ?></th>
        </tr>
    </thead>
    <tbody>
        <tr class="items">
            <td class="first center"><img 	title="<?php echo ucfirst($txt->getWord('new')); ?>"
                                            class="icon command" 
                                            src="<?php echo SYSICONS_URL; ?>add_16.gif" 
                                            onclick="if(document.getElementById('new_atr').value != '') { edit_form.submit(); }" /></td>
            <td>
                <input class="xsmall" id="new_atr" name="new_atr[]" type="text" value="" maxlength="50" />
            </td>
            <td colspan="8">&nbsp;</td>
            <td class="last">&nbsp;</td>
        </tr>
        <?php 
        if($shop->getProductAttributes()):
        foreach($shop->getProductAttributes() as $attribute)
        {
        ?>
        <tr class="items">
            <td class="first"><?php echo $attribute->getId(); ?><input type="hidden" name="attr_id[]" value="<?php echo $attribute->getId(); ?>" /></td>
            <td>
                <input class="xsmall" name="attr_title[]" type="text" value="<?php echo $attribute->getTitle(); ?>" maxlength="50" />
            </td>
            <td>
                <input class="xsmall" name="attr_title_import[]" type="text" value="<?php echo $attribute->getTitleImport(); ?>" maxlength="50" />
            </td>
            <td>
                <select class="small" name="attr_effect[]" onchange="submit();">
                    <option value="0" <?php echo $txt->getIsSelectedHTML($attribute->getEffect(), 0); ?>><?php echo ucfirst($txt->getWord('product')); ?></option>
                    <option value="1" <?php echo $txt->getIsSelectedHTML($attribute->getEffect(), 1); ?>><?php echo ucfirst($txt->getWord('variation')); ?></option>
                </select>
            </td>
            <td>
                <select class="small" name="attr_effect_image[]" onchange="submit();">
                    <option value="0" <?php echo $txt->getIsSelectedHTML($attribute->getEffectImage(), 0); ?>><?php echo ucfirst($txt->getWord('no')); ?></option>
                    <option value="1" <?php echo $txt->getIsSelectedHTML($attribute->getEffectImage(), 1); ?>><?php echo ucfirst($txt->getWord('yes')); ?></option>
                </select>
            </td>
            <td>
                <select class="small-m" name="attr_val_types[]" onchange="submit();">
                	<option value="0" <?php echo $txt->getIsSelectedHTML($attribute->getValTypes(), 0); ?>>Text (0 -> 50 chars)</option>
                    <option value="1" <?php echo $txt->getIsSelectedHTML($attribute->getValTypes(), 1); ?>>Text (50 -> 100 chars)</option>
                	<option value="2" <?php echo $txt->getIsSelectedHTML($attribute->getValTypes(), 2); ?>>Number</option>
                    <option value="3" <?php echo $txt->getIsSelectedHTML($attribute->getValTypes(), 3); ?>>Price</option>
                    <option value="4" <?php echo $txt->getIsSelectedHTML($attribute->getValTypes(), 4); ?>>Boolean (1 or 0)</option>
                    <option value="5" <?php echo $txt->getIsSelectedHTML($attribute->getValTypes(), 5); ?>>Upload</option>
                </select>
            </td>
            <td>
                <select class="xsmall" name="attr_predefined[]" onchange="submit();">
                	<?php if($attribute->getValTypes() != 6): ?>
                    <option value="0" <?php echo $txt->getIsSelectedHTML($attribute->getPredefined(), 0); ?>><?php echo ucfirst($txt->getWord('no')); ?></option>
                    <?php endif; ?>
                    <option value="1" <?php echo $txt->getIsSelectedHTML($attribute->getPredefined(), 1); ?>><?php echo ucfirst($txt->getWord('yes')); ?></option>
                </select>
            </td>
            <td>
                <select class="small-m" name="attr_type[]" onchange="submit();">
                	<?php if($attribute->getValTypes() == 5): ?>
                    <option value="3" <?php echo $txt->getIsSelectedHTML($attribute->getType(), 3); ?>><?php echo ucfirst($txt->getWord('image')); ?></option>
                    <option value="4" <?php echo $txt->getIsSelectedHTML($attribute->getType(), 4); ?>>Text</option>
                    <?php else: ?>
                    <option value="0" <?php echo $txt->getIsSelectedHTML($attribute->getType(), 0); ?>>Label</option>
                    <?php if($attribute->getEffect() == 1): ?>
                    <option value="1" <?php echo $txt->getIsSelectedHTML($attribute->getType(), 1); ?>>Selectable Option</option>
                    <option value="2" <?php echo $txt->getIsSelectedHTML($attribute->getType(), 2); ?>>Radio Buttons</option>
                    <?php endif; ?>
                    <?php endif; ?>
                </select>
            </td>
            <td>
                <select class="xsmall" name="attr_display[]" onchange="submit();">
                    <option value="0" <?php echo $txt->getIsSelectedHTML($attribute->getDisplay(), 0); ?>><?php echo ucfirst($txt->getWord('no')); ?></option>
                    <option value="1" <?php echo $txt->getIsSelectedHTML($attribute->getDisplay(), 1); ?>><?php echo ucfirst($txt->getWord('yes')); ?></option>
                </select>
            </td>
            <td>
                <select class="xsmall" name="attr_display_list[]" onchange="submit();">
                    <option value="0" <?php echo $txt->getIsSelectedHTML($attribute->getDisplayList(), 0); ?>><?php echo ucfirst($txt->getWord('no')); ?></option>
                    <option value="1" <?php echo $txt->getIsSelectedHTML($attribute->getDisplayList(), 1); ?>><?php echo ucfirst($txt->getWord('yes')); ?></option>
                </select>
            </td>
            <td>
                <select class="xsmall" name="attr_display_all[]" onchange="submit();">
                    <option value="0" <?php echo $txt->getIsSelectedHTML($attribute->getDisplayAll(), 0); ?>><?php echo ucfirst($txt->getWord('no')); ?></option>
                    <option value="1" <?php echo $txt->getIsSelectedHTML($attribute->getDisplayAll(), 1); ?>><?php echo ucfirst($txt->getWord('yes')); ?></option>
                </select>
            </td>
            <td class="center">
				<?php echo $commander->getActivationFieldsObject($attribute); ?>
                <input type="hidden" name="attr_active[]" value="<?php echo $attribute->getActive(); ?>" />
            </td>
            <td class="center">
            	<?php if($attribute->getPredefined() == 1): ?>
            	<a href="?con=<?php echo $_REQUEST['con']; ?>&attribute=<?php echo $attribute->getId(); ?>"><img class="icon command" src="<?php echo SYSICONS_URL; ?>edit_16.gif" onclick="edit_form.submit();"  /></a>
                <?php endif; ?>
            </td>
            <td class="last center">
            	<img title="<?php echo ucfirst($txt->getWord('delete').' '.$txt->getWord('attribute')); ?>" class="icon command delete_att" src="<?php echo SYSICONS_URL; ?>delete_16.gif" onclick="deleteDialog(<?php echo $attribute->getId(); ?>);" />
            </td>
        </tr>
        <?php
        }
        endif; 
        ?>
	</tbody>
</table>
</div>
<script type="text/javascript">
function deleteDialog(itemId)
{
	jQuery('#delete_dialog').dialog('open');
	jQuery('#delete_dialog').dialog({
		bgiframe: true,
		resizable: false,
		height:140,
		modal: true,
		overlay: 
		{
			backgroundColor: '#000',
			opacity: 0.5
		},
		buttons: 
		{
			'<?php echo ucfirst($txt->getWord('no')); ?>': function() 
			{
				jQuery(this).dialog('close');
			},
			'<?php echo ucfirst($txt->getWord('delete').' '.$txt->getWord('attribute').' '.$txt->getWord('value')); ?>': function() 
			{
				jQuery('#del_att_id').val(itemId);
				jQuery(this).dialog('close');
				jQuery('#edit_form').submit();
			}
		}
	});
}
</script>
<div id="delete_dialog" title="<?php echo ucfirst($txt->getWord('delete').' '.$txt->getWord('attribute')); ?>?" style="display:none; text-align:left;">
	<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span><?php echo ucfirst($txt->getWord('sure_you_want_to_delete')); ?></p>
</div>